﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MossmanMill.DataModel
{
    /// <summary>
    /// Database Access (DAO Gateway) Factory
    /// </summary>
    /// <dates>
    /// 22/05/2012 - created
    /// </dates>
    public class DBFactory : IDBFactory
    {
        public const string CLASS_TYPE_DATABASE = "Database";

        private const string ERR_MESSAGE_CLASS_NOT_FOUND = "DB Factory cannot create: {0} class.";

        public IDatabaseAccess Make(string name)
        {
            IDatabaseAccess iDatabaseAccess = null;

            switch (name)
            {

                // Create Database DAO class
                case CLASS_TYPE_DATABASE:

                    // Get Singleton DatabaseAccess instance
                    iDatabaseAccess = DatabaseAccess.Instance;
                    
                    return iDatabaseAccess;

                default:
                    throw new Exception(String.Format(ERR_MESSAGE_CLASS_NOT_FOUND, name));
            }
        }
    }
}
